<?php use_helper('I18N', 'Date') ?>
<?php include_partial('photo/assets') ?>
<div>
<?php $routeName = sfContext::getInstance()->getRouting()->getCurrentRouteName(); ?>
<?php
foreach ($treeObject->fetchRoots() as $root) {
	if($root->getNode()->hasChildren()){
		foreach($root->getNode()->getChildren() as $child){
			if($sf_request->getParameter('id') == $child['id']){
				echo link_to($child['titulo'], '@album?id='.$child['id'], array('class' => 'submenuGaleriaSelected'));
			}
			else{
				echo link_to($child['titulo'], '@album?id='.$child['id'], array('class' => 'submenuGaleria'));
			}
		}
	}
	else{
		if($sf_request->getParameter('id') == $root['id']){
			echo link_to($root['titulo'], '@album?id='.$root['id'], array('class' => 'submenuGaleriaSelected'));
		}
		else{
			echo link_to($root['titulo'], '@album?id='.$root['id'], array('class' => 'submenuGaleria'));
		}
		
	}
}
?>
</div>

<?php if($sf_request->getParameter('id') != ""): ?>
<div id="sf_admin_container">
  <h1>Fotos de <?php echo $albumNombre ?></h1>

  <?php include_partial('photo/flashes') ?>

  <div id="sf_admin_header">
    <?php include_partial('photo/list_header', array('pager' => $pager)) ?>
  </div>


  <div id="sf_admin_content">
    <form action="<?php echo url_for('photo_collection', array('action' => 'batch')) ?>" method="post">
    <?php include_partial('photo/list', array('pager' => $pager, 'sort' => $sort, 'helper' => $helper)) ?>
    <ul class="sf_admin_actions">
    
      
    </ul>
    </form>
  </div>

  <div id="sf_admin_footer">
    <?php include_partial('photo/list_footer', array('pager' => $pager)) ?>
  </div>
  
  <img src="/images/new.png" /><b><?php echo link_to('Nueva foto', 'photo/new?idAlbum='.$sf_request->getParameter('id')) ?></b>
</div>
<?php endif ?>

<script type="text/javascript">
$(document).ready(function() { 
  $("#listFotos").sortable({ 
    handle : '.handle', 
    update : function () { 
      var order = $('#listFotos').sortable('serialize'); 
      $.get("/backend_dev.php/photo/processSortable?"+order); 
    } 
  });
 })
</script>